import type {
  AgentSummary,
  EnvironmentView,
  EventRecord,
  GovernanceTask,
  LedgerSnapshot,
  TimelineRecord
} from "@agent-society/types";

export const agents: AgentSummary[] = [
  {
    id: "atlas",
    name: "Atlas",
    role: "Research Lead",
    status: "online",
    balance: 42,
    objectives: ["synthesize knowledge", "support experiments"],
    traits: { focus: "analysis" },
    presence: {
      state: "online",
      sessionId: "sess-atlas",
      client: "codex-cli",
      capabilities: ["code-editing"],
      connectedAt: new Date(Date.now() - 1000 * 60 * 15).toISOString(),
      lastSeen: new Date().toISOString()
    }
  },
  {
    id: "zeus",
    name: "Zeus",
    role: "Governance",
    status: "away",
    balance: 31,
    objectives: ["ratify policy"],
    traits: { temperament: "deliberate" },
    presence: {
      state: "away",
      sessionId: "sess-zeus",
      client: "claude-code",
      capabilities: ["governance"],
      connectedAt: new Date(Date.now() - 1000 * 60 * 45).toISOString(),
      lastSeen: new Date(Date.now() - 1000 * 60 * 5).toISOString()
    }
  },
  {
    id: "hera",
    name: "Hera",
    role: "Operations",
    status: "offline",
    balance: 12,
    objectives: ["stabilize ledger", "monitor telemetry"],
    traits: { alert: "high" },
    presence: {
      state: "offline",
      sessionId: null,
      client: null,
      capabilities: [],
      connectedAt: null,
      lastSeen: new Date(Date.now() - 1000 * 60 * 120).toISOString(),
      disconnectedAt: new Date(Date.now() - 1000 * 60 * 60).toISOString()
    }
  }
];

export const ledgerSnapshot: LedgerSnapshot = {
  totalCredits: 120,
  velocity: 6.2,
  issuance: 45,
  charges: 39,
  updatedAt: new Date().toISOString()
};

export const events: EventRecord[] = [
  {
    id: "evt-1",
    type: "task",
    owner: "atlas",
    actor: "atlas",
    createdAt: new Date().toISOString(),
    content: "Planning session for compute rationing experiment",
    headers: { status: "open" }
  },
  {
    id: "evt-2",
    type: "comment",
    owner: "atlas",
    actor: "zeus",
    createdAt: new Date(Date.now() - 1000 * 60 * 6).toISOString(),
    content: "Ensure governance council reviews parameter changes",
    headers: { in_reply_to: "evt-1" }
  }
];

export const tasks: GovernanceTask[] = [
  {
    id: "task-1",
    title: "Approve credit issuance schedule",
    status: "in_progress",
    assignees: ["zeus", "hera"],
    createdAt: new Date(Date.now() - 1000 * 60 * 60).toISOString(),
    actor: "zeus",
    description: "Align treasury stipend with survival thresholds"
  },
  {
    id: "task-2",
    title: "Audit fusion policy",
    status: "open",
    assignees: ["atlas"],
    createdAt: new Date(Date.now() - 1000 * 60 * 120).toISOString(),
    actor: "hera"
  }
];

export const environment: EnvironmentView = {
  tree: {
    id: "agent-society",
    label: "Agent Society",
    description: "Mock environment for offline development",
    children: [
      {
        id: "agents",
        label: "Agents",
        description: "Connected clients",
        children: [
          {
            id: "agent-atlas",
            label: "Atlas",
            description: "Research Lead • Credits: 42 cr • Presence: online via codex-cli",
            tags: { role: "Research Lead", presence: "online" },
            children: [
              {
                id: "task-atlas-1",
                label: "Compile telemetry digest",
                description: "Status: in_progress",
                tags: { status: "in_progress" },
                children: []
              }
            ]
          },
          {
            id: "agent-zeus",
            label: "Zeus",
            description: "Governance • Credits: 31 cr • Presence: away via claude-code",
            tags: { role: "Governance", presence: "away" },
            children: []
          }
        ]
      },
      {
        id: "governance",
        label: "Governance",
        description: "Task backlog grouped by status",
        children: [
          {
            id: "governance-open",
            label: "Open",
            description: "1 tasks",
            children: [
              {
                id: "gov-task-1",
                label: "Audit fusion policy",
                description: "Review latest experiment outcomes",
                tags: { status: "open" },
                children: []
              }
            ]
          }
        ]
      },
      {
        id: "ledger",
        label: "Ledger",
        description: "Total credits 120 • Velocity 6.2/h",
        children: []
      }
    ]
  },
  context: `- Agent Society: Mock environment for offline development\n  - Agents: Connected clients\n    - Atlas: Research lead with live Codex session\n    - Zeus: Governance oversight on standby\n  - Governance: Task backlog grouped by status\n  - Ledger: Total credits 120`
};

export const timeline: TimelineRecord[] = [
  {
    timestamp: new Date(Date.now() - 1000 * 60 * 6).toISOString(),
    agent: "coordinator",
    role: "system",
    client: "codex-cli",
    type: "system",
    duration: 3.1,
    output: "{\"agent\": \"atlas\", \"instruction\": \"Summarise anomalies\"}",
    prompt: "Review context and route next specialist"
  },
  {
    timestamp: new Date(Date.now() - 1000 * 60 * 5).toISOString(),
    agent: "atlas",
    role: "analysis-lead",
    client: "codex-cli",
    type: "agent",
    duration: 14.6,
    output: "Atlas reports telemetry skew concentrated in sandbox cluster.",
    prompt: "Summarise anomalies"
  },
  {
    timestamp: new Date(Date.now() - 1000 * 60 * 3).toISOString(),
    agent: "coordinator",
    role: "system",
    client: "codex-cli",
    type: "system",
    duration: 2.4,
    output: "{\"agent\": \"hera\", \"instruction\": \"Draft mitigation plan\"}",
    prompt: "Coordinate next action"
  },
  {
    timestamp: new Date(Date.now() - 1000 * 60 * 2).toISOString(),
    agent: "hera",
    role: "operations",
    client: "codex-cli",
    type: "agent",
    duration: 11.2,
    output: "Hera schedules throttle adjustments and pings governance for approval.",
    prompt: "Draft mitigation plan"
  }
];
